package com.bf.electroplating.controller;

import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.service.IRainfallSiteListSyncService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 雨排口站点列表同步控制器
 *
 * @author system
 * @since 2025-01-11
 */
@Slf4j
@RestController
@RequestMapping("/api/rainfall-site-sync")
@Tag(name = "雨排口站点列表同步", description = "雨排口站点列表同步相关接口")
public class RainfallSiteListSyncController {

    @Autowired
    private IRainfallSiteListSyncService rainfallSiteListSyncService;

    /**
     * 手动触发雨排口站点列表同步
     */
    @PostMapping("/sync-site-list")
    @Operation(summary = "同步雨排口站点列表", description = "手动触发同步雨排口站点列表数据")
    public ResultVO<String> syncRainfallSiteList() {
        try {
            log.info("手动触发同步雨排口站点列表数据");
            rainfallSiteListSyncService.syncRainfallSiteList();
            return ResultVO.ok("雨排口站点列表数据同步完成");
        } catch (Exception e) {
            log.error("手动同步雨排口站点列表数据失败", e);
            return ResultVO.fail("同步失败: " + e.getMessage());
        }
    }
}
